home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / gfx / x11 / x3270_3_2_16.lha / amiga_src / Cme.c < prev    next >
C/C++ Source or Header  |  2001-06-23  |  8KB  |  269 lines

  1. /* (from) $XConsortium: Sme.c,v 1.9 91/02/17 16:44:14 rws Exp $ */
  2.  
  3. /*
  4.  * Modifications Copyright 1995, 1999, 2000 by Paul Mattes.
  5.  *  Permission to use, copy, modify, and distribute this software and its
  6.  *  documentation for any purpose and without fee is hereby granted,
  7.  *  provided that the above copyright notice appear in all copies and that
  8.  *  both that copyright notice and this permission notice appear in
  9.  *  supporting documentation.
  10.  *
  11.  * Copyright 1989 Massachusetts Institute of Technology
  12.  *
  13.  * Permission to use, copy, modify, distribute, and sell this software and its
  14.  * documentation for any purpose is hereby granted without fee, provided that
  15.  * the above copyright notice appear in all copies and that both that
  16.  * copyright notice and this permission notice appear in supporting
  17.  * documentation, and that the name of M.I.T. not be used in advertising or
  18.  * publicity pertaining to distribution of the software without specific,
  19.  * written prior permission.  M.I.T. makes no representations about the
  20.  * suitability of this software for any purpose.  It is provided "as is"
  21.  * without express or implied warranty.
  22.  *
  23.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  24.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  25.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  26.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  27.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  28.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29.  */
  30.  
  31. /*
  32.  * Cme.c - Source code for the generic menu entry
  33.  * (from) Sme.c - Source code for the generic menu entry
  34.  *
  35.  * Date:    September 26, 1989
  36.  *
  37.  * By:      Chris D. Peterson
  38.  *          MIT X Consortium 
  39.  *          kit@expo.lcs.mit.edu
  40.  */
  41.  
  42. #include "globals.h"
  43. #if defined(X3270_MENUS) /*[*/
  44.  
  45. #include <stdio.h>
  46. #include <X11/IntrinsicP.h>
  47. #include <X11/StringDefs.h>
  48.  
  49. #include <X11/Xaw/XawInit.h>
  50. #include "CmeP.h"
  51. #include <X11/Xaw/Cardinals.h>
  52.  
  53. #define offset(field) XtOffsetOf(CmeRec, cme.field)
  54. static XtResource resources[] = {
  55.   {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
  56.      offset(callbacks), XtRCallback, (XtPointer)NULL},
  57. };   
  58. #undef offset
  59.  
  60. /*
  61.  * Semi Public function definitions. 
  62.  */
  63.  
  64. static void Highlight(Widget);
  65. static void Unhighlight(Widget);
  66. static void Notify(Widget);
  67. static void ClassPartInitialize(WidgetClass);
  68. static void Initialize(Widget, Widget, ArgList, Cardinal *);
  69. static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
  70.     XtWidgetGeometry *);
  71.  
  72. #ifndef AMIGA
  73. #define SUPERCLASS (&rectObjClassRec)
  74. #else
  75. #define SUPERCLASS (rectObjClass)
  76. #endif
  77.  
  78. void relay_func3(void)
  79. {
  80. XawInitializeWidgetSet();
  81. }
  82.  
  83. CmeClassRec cmeClassRec = {
  84.   {
  85.     /* superclass         */    (WidgetClass) 0,
  86.     /* class_name         */    "Cme",
  87.     /* size               */    sizeof(CmeRec),
  88.     /* class_initialize   */    0,
  89.     /* class_part_initialize*/    ClassPartInitialize,
  90.     /* Class init'ed      */    FALSE,
  91.     /* initialize         */    Initialize,
  92.     /* initialize_hook    */    NULL,
  93.     /* realize            */    NULL,
  94.     /* actions            */    NULL,
  95.     /* num_actions        */    ZERO,
  96.     /* resources          */    resources,
  97.     /* resource_count     */    0,
  98.     /* xrm_class          */    NULLQUARK,
  99.     /* compress_motion    */    FALSE, 
  100.     /* compress_exposure  */    FALSE,
  101.     /* compress_enterleave*/     FALSE,
  102.     /* visible_interest   */    FALSE,
  103.     /* destroy            */    NULL,
  104.     /* resize             */    NULL,
  105.     /* expose             */    NULL,
  106.     /* set_values         */    NULL,
  107.     /* set_values_hook    */    NULL,
  108.     /* set_values_almost  */    0,  
  109.     /* get_values_hook    */    NULL,            
  110.     /* accept_focus       */    NULL,
  111.     /* intrinsics version */    0,
  112.     /* callback offsets   */    NULL,
  113.     /* tm_table          */    NULL,
  114.     /* query_geometry      */    QueryGeometry,
  115.     /* display_accelerator*/    NULL,
  116.     /* extension      */    NULL
  117.   },{
  118.     /* Complex Menu Entry Fields */
  119.       
  120.     /* highlight */             Highlight,
  121.     /* unhighlight */           Unhighlight,
  122.     /* notify */        Notify,        
  123.     /* extension */             NULL                
  124.   }
  125. };
  126.  
  127. WidgetClass cmeObjectClass = (WidgetClass) &cmeClassRec;
  128.  
  129.  
  130. #ifdef AMIGA
  131. void AMIGA_INIT_CME(void)
  132.  {
  133.  cmeClassRec.superclass=SUPERCLASS;
  134.  cmeClassRec.class_initialize=relay_func3;
  135.  cmeClassRec.set_values_almost=XtInheritSetValuesAlmost;
  136.  cmeClassRec.num_resources=XtNumber(resources);
  137.  cmeClassRec.version=XtVersion;
  138.  }
  139. #endif
  140.  
  141. /************************************************************
  142.  *
  143.  * Semi-Public Functions.
  144.  *
  145.  ************************************************************/
  146.  
  147. /*    Function Name: ClassPartInitialize
  148.  *    Description: handles inheritance of class functions.
  149.  *    Arguments: class - the widget classs of this widget.
  150.  *    Returns: none.
  151.  */
  152.  
  153. static void
  154. ClassPartInitialize(WidgetClass class)
  155. {
  156.     CmeObjectClass m_ent, superC;
  157.  
  158.     m_ent = (CmeObjectClass) class;
  159.     superC = (CmeObjectClass) m_ent->rect_class.superclass;
  160.  
  161. /* 
  162.  * We don't need to check for null super since we'll get to TextSink
  163.  * eventually.
  164.  */
  165.  
  166. #ifndef AMIGA
  167.     if (m_ent->cme_class.highlight == XtInheritHighlight) 
  168.     m_ent->cme_class.highlight = superC->cme_class.highlight;
  169.  
  170.     if (m_ent->cme_class.unhighlight == XtInheritUnhighlight)
  171.     m_ent->cme_class.unhighlight = superC->cme_class.unhighlight;
  172.  
  173.     if (m_ent->cme_class.notify == XtInheritNotify) 
  174.     m_ent->cme_class.notify = superC->cme_class.notify;
  175. #endif
  176. }
  177.  
  178. /*      Function Name: Initialize
  179.  *      Description: Initializes the complex menu widget
  180.  *      Arguments: request - the widget requested by the argument list.
  181.  *                 new     - the new widget with both resource and non
  182.  *                           resource values.
  183.  *      Returns: none.
  184.  * 
  185.  * MENU ENTRIES CANNOT HAVE BORDERS.
  186.  */
  187.  
  188. static void
  189. Initialize(Widget request unused, Widget new, ArgList args unused,
  190.     Cardinal *num_args unused)
  191. {
  192.     CmeObject entry = (CmeObject) new;
  193.  
  194.     entry->rectangle.border_width = 0;
  195. }
  196.  
  197. /*    Function Name: Highlight
  198.  *    Description: The default highlight proceedure for menu entries.
  199.  *    Arguments: w - the menu entry.
  200.  *    Returns: none.
  201.  */
  202.  
  203. static void
  204. Highlight(Widget w unused)
  205. {
  206. /* This space intentionally left blank. */
  207. }
  208.  
  209. /*    Function Name: Unhighlight
  210.  *    Description: The default unhighlight proceedure for menu entries.
  211.  *    Arguments: w - the menu entry.
  212.  *    Returns: none.
  213.  */
  214.  
  215. static void
  216. Unhighlight(Widget w unused)
  217. {
  218. /* This space intentionally left blank. */
  219. }
  220.  
  221. /*    Function Name: Notify
  222.  *    Description: calls the callback proceedures for this entry.
  223.  *    Arguments: w - the menu entry.
  224.  *    Returns: none.
  225.  */
  226.  
  227. static void
  228. Notify(Widget w)
  229. {
  230.     XtCallCallbacks(w, XtNcallback, NULL);
  231. }
  232.  
  233. /*    Function Name: QueryGeometry.
  234.  *    Description: Returns the preferred geometry for this widget.
  235.  *    Arguments: w - the menu entry object.
  236.  *                 itended, return - the intended and return geometry info.
  237.  *    Returns: A Geometry Result.
  238.  *
  239.  * See the Intrinsics manual for details on what this function is for.
  240.  * 
  241.  * I just return the height and a width of 1.
  242.  */
  243.  
  244. static XtGeometryResult
  245. QueryGeometry(Widget w, XtWidgetGeometry *intended,
  246.     XtWidgetGeometry *return_val)
  247. {
  248.     CmeObject entry = (CmeObject) w;
  249.     Dimension width;
  250.     XtGeometryResult ret_val = XtGeometryYes;
  251.     XtGeometryMask mode = intended->request_mode;
  252.  
  253.     width = 1;            /* we can be really small. */
  254.  
  255.     if ( ((mode & CWWidth) && (intended->width != width)) ||
  256.      !(mode & CWWidth) ) {
  257.     return_val->request_mode |= CWWidth;
  258.     return_val->width = width;
  259.     mode = return_val->request_mode;
  260.     
  261.     if ( (mode & CWWidth) && (width == entry->rectangle.width) )
  262.         return(XtGeometryNo);
  263.     return(XtGeometryAlmost);
  264.     }
  265.     return(ret_val);
  266. }
  267.  
  268. #endif /*]*/
  269.